<!-- 九种体质 -->
<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb-8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleOpen()"
          >新增体质</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" @click="goSet"
          >体质问答分值设置</el-button
        >
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="dataList">
      <el-table-column
        label="体质名称"
        align="center"
        prop="constitutionaName"
      />
      <el-table-column
        label="体质类型"
        align="center"
        prop="constitutionaType"
      />
      <el-table-column label="总体特征" align="center" prop="totalFeature" />
      <el-table-column label="形体特征" align="center" prop="formFeature" />
      <el-table-column
        label="心理特征"
        align="center"
        prop="psychologyFeature"
      />
      <el-table-column
        label="发病倾向"
        align="center"
        prop="pathogenicTendency"
      />
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        width="150"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="120px"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleOpen(scope.row.id)"
            >编辑</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <EditCorporeity ref="EditCorporeity" @refresh="getList" />
  </div>
</template>

<script>
import { getConstitutionList } from "@/api/saas/tcm.js";
import EditCorporeity from "./editCorporeity";

export default {
  name: "Corporeity",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        keyword: "",
      },
      // 总条数
      total: 0,
      dataList: [],
    };
  },
  components: {
    EditCorporeity,
  },
  created() {
    this.getList();
  },
  activated() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      getConstitutionList(this.queryParams)
        .then((response) => {
          this.dataList = response.rows;
          this.total = response.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    resetQuery() {
      Object.assign(this.$data.queryParams, this.$options.data().queryParams);
      this.getList();
    },
    handleOpen(id) {
      this.$refs.EditCorporeity.openModal(id);
    },
    goSet() {
      this.$router.push({path: `/saas/corporeityScore/index`})
    }
  },
};
</script>

<style lang="scss" scoped></style>
